/**
 * \file
 *          teleMainBLThread.h
 * \brief
 *          Implements starter thread of entTelematicsMain
 *
 * \par Author (last changes):
 *          - Song Yang
 *          - Phone +65 65800179
 *          - Continental Automotive Singapore
 * \par Project Leader:
 *          - Mandy Sin
 *          - Phone +65 67799 819
 *          - Mandy.Sin@continental-corporation.com
 * \par Responsible Developer:
 *          - Song Yang
 *          - Phone +65 65800179
 *          - Continental Automotive Singapore
 * \par Responsible Architect:
 *          - Goh Hoe Chun
 *          - Phone +65 67799 586
 *          - Hoe.Chun.Goh@continental-corporation.com
 *
 * \par Project:
 *      DPCA2
 *
 * \par SW-Component:
 *      teleMainBLThread
 *
 * \par SW-Package:
 *      Telematics Main
 *
 * \par SW-Module:
 *      Telematics Main
 *
 * \par SW-Architecture Specification:
 *      DPCA_SW_AD_IMX
 *      003
 *
 * \par SW-Design Specification:
 *      DPCA_your_module_SW_DD
 *      your_doc_number
 *
 * \par SW-Test Case Specification:
 *      DPCA_your_module_SW_TS
 *      your_doc_number
 *
 * \par CM-Info:
 *      - teleMainBLThread.h-1:incl:DPCARSgp#1
 *      - uidc1282
 *
 * \note
 *      This is a note.
 *
 * \bug
 *      - there are no known bugs
 *
 * \par Module-History:
 *
 * \verbatim
 * Date                Author                 Reason
 * 20 Dec 2012         Song Yang           Initial Creation
 * The latest entry at the head of the history list.
 * \endverbatim
 *
 * \par Copyright Notice:
 * Copyright (C) 2011 Continental Automotive Singapore Pte Ltd.
 * Alle Rechte vorbehalten. All Rights Reserved.\n
 * The reproduction, transmission or use of this document or its contents is
 * not permitted without express written authority.\n
 * Offenders will be liable for damages. All rights, including rights created
 * by patent grant or registration of a utility model or design, are reserved.
 *
 * \ingroup GEN_TELE_MAIN
 */
 
#pragma once

#include "RPCThread.h"
#include "HiGraphBase.h"

#include "ThreadSignal.h"
#include "ThreadAlarm.h"
#include "ObsObr.h"

enum teleHigraph
{
//    gConnMgrState=0,
    gEcallBLState=0,
    gBcallBLState,
    gUsbDiagBL,   
    gRmtCfgSetState,
    gRmtCfgGetState,
	gPushObjState,
	gRmtCfgMonitorState,
	gUrlBackBL,
    gMAXTELE
};

class teleMainBLThread;
class teleHigraphSignal;
class teleHigraphAlarm;
class tele_obr;

/**
* \brief
*  This class handle the higraph signal of telematics
*/
class teleHigraphSignal:public ThreadSignal
{
public:
	teleHigraphSignal(LPCWSTR pName,bool bManual);

   ~teleHigraphSignal();

   virtual void hook(Thread*t);
};

/**
* \brief
*  This class handle the higraph alarm of telematics
*/
class teleHigraphAlarm : public ThreadAlarm
{
public:

    teleHigraphAlarm(uint32_t delay, bool autoset, bool repeat );

    virtual ~teleHigraphAlarm();

    virtual void hook ( Thread * t );
};


/**
 * \brief
 * This class handle of the Telematics Business Logic thread.
 */
class teleMainBLThread : public RPCThread 
{
public:
    teleMainBLThread ( char * name, ThreadPriorityType priority, ThreadStackSizeType stackSize );
    virtual ~teleMainBLThread();

    static teleMainBLThread* getInstance();

    virtual void instantiate();
    virtual void initialize ();
    virtual void preInstantiate();

    void processEvent();

    void processAlarm();

    void deInitialize();
private:	
		uint8_t IsKitlEnable(void);

public:

    teleHigraphAlarm *mpHigraphAlarm;      /**< pointer to instance of higraph alarm */

    MutexLock* mpTeleQueueMutex;           /**< pointer to mutex instance of alert queue */

    uc8_t mStateMachinesSize;            /**< state machine size */

    teleHigraphSignal* mpSignalHigraph;    /**< pointer to instance of higraph signal */

    static HiGraphBase **mpStateMachines; /**< static pointer to mutex instance of state machines */

    tele_obr* pObr;

};


class tele_obr:public ObsObr
{
public:
	tele_obr(void);
	~tele_obr(void);
	void __hndUpdateByValue(ObsObd * theCallingObserved, obsObdStatus status, const uint8_t* dataPackage, const uint16_t size );

protected:

    uc8_t   mUserState;         /**< User state */
};


